import typing
from PyQt5.QtWidgets import QApplication,QWidget,QPushButton
from PyQt5 import QtCore
import sys

class MyWidget(QWidget):

    def __init__(self,title):
        super().__init__()
        self.setWindowTitle(title)
        self.resize(640,480)
        
        self.init_ui()

    def btn_clicked(self):
        print("按钮被点击")
    
    def init_ui(self):
        btn = QPushButton("按钮",self)
        btn.clicked.connect(self.btn_clicked)
if __name__ == '__main__':
    
    # 1.创建应用程序
    app = QApplication(sys.argv)
    
    # 2.创建窗口
    w = MyWidget("窗口标题")
    

    
    # 3.显示窗口
    w.show()
    # 4.等待窗口停止
    sys.exit(app.exec())